cmake_minimum_required(VERSION 3.10)

project(imagebind_yolo)


set(CMAKE_CXX_STANDARD 11)


find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)
include_directories(${JSONCPP_LIBRARIES})

find_package(OpenCV REQUIRED)
include_directories(OpenCV_INCLUDE_DIRS)
if(OpenCV_FOUND)
    message(STATUS "Found OpenCV")
    message(STATUS "Opencv Version:${OpenCV_VERSION}")
    message(STATUS "OpenCV Library: ${OpenCV_LIBS}")
    message(STATUS "Include path: ${OpenCV_INCLUDE_PATH}")
else()
    message(FATAL_ERROT "Could not find OpenCV library")
endif()


if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
    message("embed_platform on")
    include_directories(/usr/local/cuda/targets/aarch64-linux/include)
    link_directories(/usr/local/cuda/targets/aarch64-linux/lib)
else()
    message("embed_platform off")
    include_directories(/usr/local/cuda/include)
    link_directories(/usr/local/cuda/lib64)
endif()


include_directories(
  ${PROJECT_SOURCE_DIR}/include/
  ${CMAKE_BINARY_DIR}/include
  ${MICROS_INSTALL_SOFTLINK_PREFIX}/include
  #/usr/local/cuda/include
  #/usr/local/cudnn/include
  ${OpenCV_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
  ${TENSORRT_INCLUDE_DIR}
)
link_directories(
  ${PROJECT_BINARY_DIR}/lib
  ${MICROS_INSTALL_SOFTLINK_PREFIX}/lib
  #/usr/local/cuda/lib64
  #/usr/local/libs
  #/usr/lib
  ${CLASS_LOADER}
)


# include_directories(/home/xjl/software/jsoncpp-1.9.5/build/lib/)
# link_directories(/home/xjl/software/jsoncpp-1.9.5/build/lib/)
# find_library(JSON_CPP libjsoncpp.a)


include_directories(/usr/local/TensorRT-7.2.3.4/include/)
link_directories(/usr/local/TensorRT-7.2.3.4/lib/)
message(STATUS "PROJECT_SOURCE_DIR:${PROJECT_SOURCE_DIR}")
set(SRC_DIR ./src)

file(GLOB SOURCES ${SRC_DIR}/*.cpp)

message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")

add_executable(test main.cpp ${SOURCES})
target_link_libraries(test
        ${OpenCV_LIBS}
        ${CUDA_LIBRARIES}
        ${TENSORRT_LIBRARY}
        ${JSONCPP_LIBRARIES}
)

target_link_libraries(test nvinfer)
target_link_libraries(test cudart)
